//获取应用实例
const app = getApp()
Page({
  data: {
    naem: "",
    company_name: "",
    corp_name: ""
  },
  onLoad: function(options) {
    var that = this;
    var thata = this.data;
    var id = wx.getStorageSync('shuhai_party_id');
    var name = wx.getStorageSync('name');
    var shuhai = wx.getStorageSync('shuhai_jtid');
    console.log(id + "==进入到通讯录详情页获取到的数据==" + name + ">>>>>>>>>>>." + shuhai);
    wx.showLoading({
      title: '数据正在加载中',
    })
    wx.request({
      url: 'https://wxapp.shuhai.cc/hh/gain_Address_listId2.action',
      method: 'post',
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      data: {
        id: id,
      },
      success: function(res) {
        console.log(res.data);
        if (res.data.status == "success") {
          wx.hideLoading();
          wx.setStorageSync("bumen", res.data.data.company_name + "," + res.data.data.corp_name),
            that.setData({
              username: res.data.data.name, //添加姓名
              phone_list: res.data.data.phone_list, //添加手机号码的集合
              company_name: res.data.data.company_name, //添加公司的集合
              corp_name: res.data.data.corp_name, //添加部门的集合
              hebing: res.data.data.str,
              img_url: res.data.data.img_url,
            })
        } else {
          wx.hideLoading();
        }
      },
      fail: function(res) {
        wx.hideLoading();
        wx.showToast({
          title: '网络错误！',
          icon: 'none',
          duration: 2000
        })
        return;
      }
    });
  },
  goPhone: function(e) {
    var phonenum = e.currentTarget.dataset.phonenum;
    wx.makePhoneCall({
      phoneNumber: phonenum,
    })
  },
  bindFormSubmit: function(e) {
    var name = wx.getStorageSync('name');
    var company_name = wx.getStorageSync('bumen');
    var content = e.detail.value.textarea;
    console.log(name + ">>>>>>>>>>" + company_name)
    console.log("提交后的反馈意见内容：" + e.detail.value.textarea)
    wx.request({
      url: 'https://wxapp.shuhai.cc/hh/addWxIdeaAction.action',
      method: 'post',
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      data: {
        name: name,
        company_name: company_name,
        content: content
      },
      success: function(res) {
        if (content==''){
          wx.showToast({
            title: '反馈意见为空不能提交，请输入。。。',
            icon: 'none',
            duration: 1500
          })
        }
        if (res.data.status=='success'){
          wx.navigateBack({
            url: '../index/index',
          })
          wx.showToast({
            title: '提交成功',
            icon: 'success',
            duration: 500
          })
        }
        
      },
      fail: function(res) {
        wx.hideLoading();
        wx.showToast({
          title: '网络错误！',
          icon: 'none',
          duration: 2000
        })
        return;
      }
    });
  }

})